﻿@*page:WeighingRecord.razor*@
@*gardener-time:2024-07-22 16:06:16*@
@page "/weighbridge/weighing-record"
@inherits ListOperateTableBase<WeighingRecordDto, Guid, WeighingRecordEdit,WeighbridgeLocalResource>

@{
    TableFilter<IdentityType>[] identityTypeEnumFilters = EnumHelper.EnumToList<IdentityType>().Select(x => { return new TableFilter<IdentityType>() { Text = Localizer[EnumHelper.GetEnumDescriptionOrName(x)], Value = x }; }).ToArray();
}
<div>
    <Table @ref="_table"
           TItem="WeighingRecordDto"
           DataSource="_datas"
           Total="_total"
           OnChange="OnChange"
           @bind-PageSize="_pageSize"
           @bind-SelectedRows="_selectedRows"
           Loading="_tableLoading.Value"
           Context="model"
           Size="ClientConstant.DefaultTableSize"
           PaginationPosition="@ClientConstant.TablePaginationPosition"
           RemoteDataSource
           RowKey="x => x.Id">
        <TitleTemplate>
            <ResourceAuthorize ResourceKey="weighbridge_weighing_record_search">
                <TableSearch TDto="WeighingRecordDto" @ref="this._tableSearch" OnSearch="OnTableSearch" Settings="_tableSearchSettings" CustomLocalizer="Localizer" />
            </ResourceAuthorize>
            <Row>
                <AntDesign.Col Span="8">
                    <ResourceAuthorize ResourceKey="weighbridge_weighing_record_delete_selected">
                        <Button Type="@ButtonType.Primary" Icon="@IconType.Outline.Delete" Danger OnClick="OnClickDeletes" Loading="_deletesBtnLoading">
                            @Localizer[nameof(SharedLocalResource.DeleteSelected)]
                        </Button>
                    </ResourceAuthorize>
                </AntDesign.Col>
                <AntDesign.Col Span="16" Style="text-align:right">
                    <Space>
                        <ResourceAuthorize ResourceKey="weighbridge_weighing_record_add">
                            <SpaceItem>
                                <Button Type="@ButtonType.Primary" Icon="@IconType.Outline.Plus" OnClick="OnClickAdd">
                                    @Localizer[nameof(SharedLocalResource.Add)]
                                </Button>
                            </SpaceItem>
                        </ResourceAuthorize>
                        <ResourceAuthorize ResourceKey="weighbridge_weighing_record_refresh">
                            <SpaceItem>
                                <Button Type="@ButtonType.Primary" Icon="@IconType.Outline.Reload" OnClick="ReLoadTable">
                                    @Localizer[nameof(SharedLocalResource.Refresh)]
                                </Button>
                            </SpaceItem>
                        </ResourceAuthorize>
                    </Space>
                </AntDesign.Col>
            </Row>
        </TitleTemplate>
        <ColumnDefinitions>
            <Selection Hidden="@_userUnauthorizedResources["weighbridge_weighing_record_delete_selected"]" />
            <PropertyColumn Property="x => x.TenantId" Filters="_tenantFilters" Filterable Title="@Localizer[nameof(SharedLocalResource.Tenant)]" Hidden="@_userUnauthorizedResources[CommonResourceKeys.SystemTenantAdministratorKey]">
                <span>@model.Tenant?.Name</span>
            </PropertyColumn>
            <PropertyColumn Property="c => c.WeighbridgeConfig">
                @(model.WeighbridgeConfig?.Name ?? "--")
            </PropertyColumn>
            <PropertyColumn Property="c => c.PlateNumber" Filterable Sortable />
            @* <PropertyColumn Property="c => c.VehicleType" Filterable Sortable /> *@
            <PropertyColumn Property="c => c.MaximumLoad" Filterable Sortable />
            <PropertyColumn Property="c => c.Driver" Filterable Sortable />
            <PropertyColumn Property="c => c.CommodityName" Filterable Sortable />
            <PropertyColumn Property="c => c.CommodityCode" Filterable Sortable />
            <PropertyColumn Property="c => c.Weight" Filterable Sortable />
            <PropertyColumn Property="c => c.TareWeight" Filterable Sortable />
            <PropertyColumn Property="c => c.CommodityWeight" />
            <PropertyColumn Property="c => c.WeighingNumber" Filterable Sortable />
            <PropertyColumn Property="c => c.WeighingStatus" Filterable>
                <TagPro Text="model.WeighingStatus" Localizer="Localizer"></TagPro>
            </PropertyColumn>
            @*  <PropertyColumn Property="c => c.IsLocked" Filterable Sortable>
                <ResourceAuthorize ResourceKey="weighbridge_weighing_record_lock">
                    <Authorized>
                        <Switch @bind-Value="@model.IsLocked" OnChange="e => OnChangeIsLocked(model, e)" Loading="_lockBtnLoading[model]"></Switch>
                    </Authorized>
                    <NotAuthorized>
                        <TagYesNo Yes="model.IsLocked"></TagYesNo>
                    </NotAuthorized>
                </ResourceAuthorize>
            </PropertyColumn> *@
            <PropertyColumn Property="c => c.OperatorName" Filterable Sortable />
            <PropertyColumn Property="c => c.CreatedTime" Sortable DefaultSortOrder="@SortDirection.Descending" Format="@ClientConstant.DateTimeFormat" />
            <ActionColumn>
                <Space>
                    <ResourceAuthorize ResourceKey="weighbridge_weighing_record_update">
                        <SpaceItem>
                            <Tooltip Title="@Localizer[nameof(SharedLocalResource.Edit)]" ArrowPointAtCenter="true">
                                <Button Icon="@IconType.Outline.Edit" Type="@ButtonType.Primary" Size="@ClientConstant.OperationButtonSize" OnClick="() => OnClickEdit(model.Id)"></Button>
                            </Tooltip>
                        </SpaceItem>
                    </ResourceAuthorize>
                    <ResourceAuthorize ResourceKey="weighbridge_weighing_record_detail">
                        <SpaceItem>
                            <Tooltip Title="@Localizer[nameof(SharedLocalResource.Detail)]" ArrowPointAtCenter="true">
                                <Button Icon="@IconType.Outline.Eye" Type="@ButtonType.Primary" Size="@ClientConstant.OperationButtonSize" OnClick="() => OnClickDetail(model.Id)"></Button>
                            </Tooltip>
                        </SpaceItem>
                    </ResourceAuthorize>
                    <ResourceAuthorize ResourceKey="weighbridge_weighing_record_log_detail">
                        <SpaceItem>
                            <Tooltip Title="@Localizer[nameof(WeighbridgeLocalResource.WeighingRecordLog)]" ArrowPointAtCenter="true">
                                <Button Icon="iconfont icon-logs" Type="@ButtonType.Primary" Size="@ClientConstant.OperationButtonSize" OnClick="() => OpenWeighingRecordLogList(model)"></Button>
                            </Tooltip>
                        </SpaceItem>
                    </ResourceAuthorize>
                    <ResourceAuthorize ResourceKey="weighbridge_weighing_record_delete">
                        <SpaceItem>
                            <Tooltip Title="@Localizer[nameof(SharedLocalResource.Delete)]" ArrowPointAtCenter="true">
                                <Button Icon="@IconType.Outline.Delete" Type="@ButtonType.Primary" Danger OnClick="() => OnClickDelete(model.Id)"></Button>
                            </Tooltip>
                        </SpaceItem>
                    </ResourceAuthorize>
                </Space>
            </ActionColumn>
        </ColumnDefinitions>
    </Table>
</div>